<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>CalcHelper Demo</title>
    <script type="text/javascript" src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
    <script type="text/javascript" src="arrayHelper.js"></script>
    <script type="text/javascript">
        $(function(){
			var easyList = new arrayHelper();
			easyList.Add(1);
			easyList.Add(12);
			easyList.Add(43);
			easyList.Add(23);
			easyList.Add(1);//不会添加相同，只是更新
			console.log("easyList初始有" + easyList.Count() + "个");
			
			var complexList = new arrayHelper("Id");
			complexList.Add({Id:1,name:"Ken",age:18});
			complexList.Add({Id:2,name:"John",age:18});
			complexList.Add({Id:3,name:"Alice",age:19});
			complexList.Add({Id:4,name:"Delete",age:19});
			complexList.Add({Id:1,name:"Harry",age:19});//将Id为1的更新数据
			console.log("complexList" + complexList.Count() + "个");
			
			//移除
			easyList.Remove(23);//移除内容为23的
			console.log("easyList移除内容为23的后，有" + easyList.Count() + "个");
			complexList.Remove(4);//移除Id为4的
			console.log("complexList移除Id为4的后，有" + complexList.Count() + "个");
			
			//查找符合条件的第一个结果
			var result1 = easyList.FirstOrDefault(1);
			console.log(result1);
			var result2 = complexList.FirstOrDefault({Id:1});
			console.log(result2);
			
			//查找，符合条件的列表
			var result3 = easyList.Search(12);
			console.log(result3);
			var result4 = complexList.Search({age:19});
			console.log(result4);
			
			//统计
			var result5 = easyList.Count(12);
			console.log(result5);
			var result6 = complexList.Count({age:18});
			console.log(result6);
			console.log(complexList.Count());
			
        });
    </script>
</head>
<body>
	
</body>
</html>